package com.matt.repository.impl;

import com.matt.repository.QuestionReplyRecordRepository;
import com.matt.repository.base.BaseNativeSqlRepository;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/8/24
 * *******************************
 */
@Component
public class QuestionReplyRecordRepositoryImpl extends BaseNativeSqlRepository implements QuestionReplyRecordRepository {

    @Override
    public List<Object[]> findCBQuestionAndRecordByEvaluatingId(String evaluatingRecordId) {
        String querySql = String.format("SELECT q.typeName, q.title, qr.score, qr.result " +
                " from evaluating_question q  right JOIN evaluating_cb_question_record qr ON q.id = qr.questionId " +
                " where qr.evaluatingRecordId = '%s'  ", evaluatingRecordId);
        querySql += "order by q.typeCode ";

        List<Object[]> objectArrayList = sqlArrayList(querySql);
        return objectArrayList;
    }

    @Override
    public List<Object[]> findMQuestionAndRecordByEvaluatingId(String evaluatingRecordId) {
        String querySql = String.format("SELECT q.typeName, q.title, qr.score, qr.result " +
                " from evaluating_question q  right JOIN evaluating_m_question_record qr ON q.id = qr.questionId " +
                " where qr.evaluatingRecordId = '%s'  ", evaluatingRecordId);
        querySql += "order by q.typeCode ";

        List<Object[]> objectArrayList = sqlArrayList(querySql);
        return objectArrayList;
    }
}
